<?php $url = new Url();?>
<div class="left">
    <?php $this->widget("AdminQuanly")?>
</div>
<div class="right-main">
    <div class="righ-cont">
        <div class="right">
            <div class="title_style"> <span><b>Danh sách Admin</b></span></div>
            <div class="tool clearfix">
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                    <tbody>
                        <tr>
                            <td width="110" class="text-right"><label>Tên Admin</label></td>
                            <td width="200"><input type="text" value="" class="w90" /></td>
                            <td width="60" class="text-right"><label>Số ID</label></td>
                            <td width="100"><input type="text" value="" /></td>
                            <td> <input type="submit" value="Tìm kiếm"></td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <div class="table clearfix">
                <table cellspacing="0" cellpadding="0" border="0" width="100%">
                    <tbody>
                        <tr class="bg_gray">
                            <td width="8%"><b>STT</b></td>
                            <td width="14%"><strong>Admin</strong></td>
                            <td width="14%"><strong>Ngày tạo</strong></td>
                            <td width="14%"><b>Phân Quyền</b></td>
                            <td width="8%"><b>Sửa</b></td>
                            <td width="7%"><b>Xóa</b></td>
                        </tr>
                        <?php for($i=0;$i<count($rows);$i++){?>
                            <tr>
                                <td><?=$i+1 ?></td>
                                <td><?=$rows[$i]["username"] ?></td>
                                <td><?=$rows[$i]["create_date"] ?></td>
                                <td><a href="<?=$url->createUrl("admin/permit",array("id"=>$rows[$i]["id"])) ?>">Phân quyền</a></td>
                                <td class="bg_yellow"><a class="edit" href="<?=$url->createUrl("admin/edit",array("id"=>$rows[$i]["id"])) ?>">Sửa</a></td>
                                <td class="bg_yellow"><a class="del" href="javascript:void(0)" onclick="deleteAdmin('<?=$rows[$i]["id"] ?>');">Xóa</a></td>
                            </tr>
                            <?php }?>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function deleteAdmin(id){
        var strUrl = '<?=$url->createUrl("admin/delete") ?>';
        if(confirm('Bạn có chắc chắn muốn xóa không ?')){
            $.ajax({
                type: "POST",
                url: strUrl,
                data: {
                    id:id,
                },
                success: function(msg){
                    $("#save").removeClass("loading");
                    if(msg==1){       
                        alert('Sửa thành công');            
                        window.location = '<?=$url->createUrl("admin/index")?>';             
                    }else{
                        alert('Có lỗi');
                        return false;
                    }
                },
                beforeSend:function(){
                    $("#save").html("");
                    $("#save").addClass("loading");
                }
            });
        }
    }
</script>